
            
class ShirtController {
    def index = { redirect(action:list,params:params) }

    def list = {
        [ shirtList: Shirt.list( params ) ]
    }

    def show = {
        [ shirt : Shirt.get( params.id ) ]
    }

    def delete = {
        def shirt = Shirt.get( params.id )
        if(shirt) {
            shirt.delete()
            flash.message = "Shirt ${params.id} deleted."
            redirect(action:list)
        }
        else {
            flash.message = "Shirt not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def shirt = Shirt.get( params.id )

        if(!shirt) {
                flash.message = "Shirt not found with id ${params.id}"
                redirect(action:list)
        }
        else {
            return [ shirt : shirt ]
        }
    }

    def update = {
        def shirt = Shirt.get( params.id )
        if(shirt) {
             shirt.properties = params
            if(shirt.save()) {
                redirect(action:show,id:shirt.id)
            }
            else {
                render(view:'edit',model:[shirt:shirt])
            }
        }
        else {
            flash.message = "Shirt not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def shirt = new Shirt()
        shirt.properties = params
        return ['shirt':shirt]
    }

    def save = {
        def shirt = new Shirt()
        shirt.properties = params
        if(shirt.save()) {
            redirect(action:show,id:shirt.id)
        }
        else {
            render(view:'create',model:[shirt:shirt])
        }
    }

}